﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Projeto3D
{
    static class Time
    {
        private static TimeSpan interval = new TimeSpan();
        private static TimeSpan start = new TimeSpan();
        private static TimeSpan end = new TimeSpan();
        private static bool oldPause = false;

        public static double milliseconds = 0;
        public static double seconds = 0;

        public static void update(GameTime time, bool pause)
        {
            if (pause && !oldPause)
            {
                start = new TimeSpan(0, 0, 0, 0, (int)time.TotalGameTime.TotalMilliseconds);
            }

            if (!pause && oldPause)
            {
                end = new TimeSpan(0, 0, 0, 0, (int)time.TotalGameTime.TotalMilliseconds);

                TimeSpan dif = end.Subtract(start);

                interval = interval.Add(dif);
            }

            if (!pause)
            {
                milliseconds = time.TotalGameTime.TotalMilliseconds - interval.TotalMilliseconds;
                seconds = time.TotalGameTime.TotalSeconds - interval.TotalSeconds;
            }

            oldPause = pause;
        }
    }
}
